package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mapper.QuestionMapper;
import com.tanhua.model.domain.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class QuestionApiImpl implements QuestionApi {

    @Autowired
    private QuestionMapper mapper;

    //根据id查询问题数据
    @Override
    public Question findByUserId(Long userId) {
        QueryWrapper<Question> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        return mapper.selectOne(wrapper);
    }

    //添加问题数据
    @Override
    public void addQuestion(Question byUserId) {
        //添加数据
         mapper.insert(byUserId);
    }

    //修改问题数据
    @Override
    public void updateQuestion(Question byUserId) {
        //.修改数据
        mapper.updateById(byUserId);
    }
}
